package com.example.demo.mapper;

import com.example.demo.entity.UserService;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserServiceMapper {
    @Insert("INSERT INTO user_service (user_id, status, expiry_time) " +
            "VALUES (#{userId}, #{status},#{expiryTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insertUserService(UserService userService);

    // 更新用户服务状态和到期时间
    @Update("UPDATE user_service SET status = #{status}, expiry_time = #{expiryTime}" +
            " WHERE user_id = #{userId}")
    void updateUserService(UserService userService);
    @Select("SELECT COUNT(*) FROM user_service WHERE user_id = #{userId}")
    int countByUserId(int userId);

    @Select("SELECT expiry_time FROM user_service WHERE user_id = #{user_id}")
    String getExpiryTimeById(int user_id);
}
